package com.hbsoft.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.hbsoft.util.*;
import com.hbsoft.vo.UserInfoVo;

public class LoginDao 
{
	private List<UserInfoVo> list = null;
	private DBUtil util = null;
	private SqlConfig conf = null;
	private String selectUserInfoSql = null;
	
	public LoginDao()
	{
		list = new ArrayList<UserInfoVo>();
		util = DBUtil.getInstance();
		conf = SqlConfig.getInstance();
		selectUserInfoSql = conf.getSelectUserInfoSql();
	}
	
	public List<UserInfoVo> getUserInfoVoList() throws SQLException
	{
		
		Connection con = util.getConnection();
		
		PreparedStatement ps = con.prepareStatement(selectUserInfoSql);
		ResultSet rst = ps.executeQuery();
		while(rst.next())
		{
			UserInfoVo vo = new UserInfoVo();
			vo.setUserName(rst.getString("userName"));
			vo.setPassword(rst.getString("password"));
			list.add(vo);
		}
		return list;
	}
}
